package com.mf.controller.queue;

import com.mf.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.PriorityBlockingQueue;

/**
 * @Author: lmf
 * @Create: 2025/5/22 22:16
 * @module 优先级队列
 */
@RestController
@RequestMapping("/priorityBlockIngQueue")
public class PriorityBlockIngQueueUse {
    @Operation(summary = "根据队列值可以排序后的输出")
    @GetMapping("add")
    public Result<String> add() {
        final PriorityBlockingQueue<Integer> queue = new PriorityBlockingQueue<>();
        queue.add(1);
        queue.add(3);
        queue.add(2);

        System.out.println(queue.poll());
        System.out.println(queue.poll());
        System.out.println(queue.poll());
        System.out.println(queue.poll());
        return Result.success();
    }

}
